<%@page import="java.util.Map.Entry"%>
<%@page import="java.util.Map"%>
<%@page import="java.math.BigDecimal"%>
<%@page import="java.lang.Integer"%>
<%@page import="java.util.Hashtable"%>
<%@page import="java.util.List"%>
<%@page import="com.qmerak.common.DataBaseUtil"%>
<%@page import="com.qmerak.common.SpringUtil"%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<link href="../../css/style_01.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../../js/jquery-1.7.2.js"></script>
<script type="text/javascript" src="../../js/highcharts.js"></script>
<script type="text/javascript" src="../../js/exporting.js"></script>
<%
	String sql = "select educational groupname,count(*) num from t_member group by educational";
	List<Hashtable<String, Object>> datas = DataBaseUtil.query(sql);
	Hashtable<String, Object> table = new Hashtable<String, Object>();
	for (Hashtable<String, Object> data : datas) {
		table.put(String.valueOf(data.get("groupname")),
				data.get("num"));
	}
	Map<String,String> rates=DataBaseUtil.calRate(table);
// 	double boshiN=Double.parseDouble(DataBaseUtil.sum(table.get("10")));
// 	double shuoshiN=Double.parseDouble(DataBaseUtil.sum(table.get("20")));
// 	double benkeN=Double.parseDouble(DataBaseUtil.sum(table.get("30")));
// 	double dazhuanN=Double.parseDouble(DataBaseUtil.sum(table.get("40")));
// 	double zhongzhuanN=Double.parseDouble(DataBaseUtil.sum(table.get("50")));
// 	double gaozhongN=Double.parseDouble(DataBaseUtil.sum(table.get("60")));
// 	double chuzhongN=Double.parseDouble(DataBaseUtil.sum(table.get("70")));
// 	double xiaoxueN=Double.parseDouble(DataBaseUtil.sum(table.get("80")));
// 	double otherN=Double.parseDouble(DataBaseUtil.sum(table.get(""),table.get("null")));
// 	double sumN=boshiN+shuoshiN+benkeN+dazhuanN+zhongzhuanN+gaozhongN+chuzhongN+xiaoxueN+otherN;
	
// 	double boshiR=new BigDecimal(boshiN/sumN*100).setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue();
// 	double shuoshiR=new BigDecimal(shuoshiN/sumN*100).setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue();
// 	double benkeR=new BigDecimal(benkeN/sumN*100).setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue();
// 	double dazhuanR=new BigDecimal(dazhuanN/sumN*100).setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue();
// 	double zhongzhuanR=new BigDecimal(zhongzhuanN/sumN*100).setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue();
// 	double gaozhongR=new BigDecimal(gaozhongN/sumN*100).setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue();
// 	double chuzhongR=new BigDecimal(chuzhongN/sumN*100).setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue();
// 	double xiaoxueR=new BigDecimal(xiaoxueN/sumN*100).setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue();
// 	double otherR=new BigDecimal(otherN/sumN*100).setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue();
	
	System.out.println("统计："+table);
%>
<script type="text/javascript">
<%-- var rate_boshi=<%=rates.get("10")%>; --%>
<%-- var rate_shuoshi=<%=rates.get("10")%>; --%>
<%-- var rate_benke=<%=rates.get("10")%>; --%>
<%-- var rate_dazhuan=<%=rates.get("10")%>; --%>
<%-- var rate_zhongzhuan=<%=String.valueOf(zhongzhuanR)%>; --%>
<%-- var rate_gaozhong=<%=String.valueOf(gaozhongR)%>; --%>
<%-- var rate_chuzhong=<%=String.valueOf(chuzhongR)%>; --%>
<%-- var rate_xiaoxue=<%=String.valueOf(xiaoxueR)%>; --%>
<%-- var rate_other=<%=String.valueOf(otherR)%>; --%>
// console.log(rate_men+";"+rate_women+";"+rate_other);

var datas=[];
<%
System.out.println(rates);
	for(Entry<String,String> entry:rates.entrySet()){
		if("10".equals(entry.getKey())){
			%>
			datas.push(["博士",<%=entry.getValue()%>]);
			<%
		}else if("20".equals(entry.getKey())){
			%>
			datas.push(["硕士",<%=entry.getValue()%>]);
			<%
		}else if("30".equals(entry.getKey())){
			%>
			datas.push({
				 name: '本科',
                 y: <%=entry.getValue()%>,
                 sliced: true,
                 selected: true
			});
			<%
		}else if("40".equals(entry.getKey())){
			%>
			datas.push(["大专",<%=entry.getValue()%>]);
			<%
		}else if("50".equals(entry.getKey())){
			%>
			datas.push(["中专",<%=entry.getValue()%>]);
			<%
		}else if("60".equals(entry.getKey())){
			%>
			datas.push(["高中",<%=entry.getValue()%>]);
			<%
		}else if("70".equals(entry.getKey())){
			%>
			datas.push(["初中",<%=entry.getValue()%>]);
			<%
		}else if("80".equals(entry.getKey())){
			%>
			datas.push(["小学",<%=entry.getValue()%>]);
			<%
		}else if("other".equals(entry.getKey())){
			%>
			datas.push(["其他",<%=entry.getValue()%>]);
			<%
		}
	}
%>

$(function () {
    $('#container').highcharts({
        chart: {
            plotBackgroundColor: null,
            plotBorderWidth: null,
            plotShadow: false
        },
        title: {
            text: '会员受教育比例图'
        },
        tooltip: {
    	    pointFormat: '{series.name}: <b>{point.percentage}%</b>',
        	percentageDecimals: 1
        },
        plotOptions: {
            pie: {
                allowPointSelect: true,
                cursor: 'pointer',
                dataLabels: {
                    enabled: true,
                    color: '#000000',
                    connectorColor: '#000000',
                    formatter: function() {
                        return '<b>'+ this.point.name +'</b>: '+ this.percentage +' %';
                    }
                }
            }
        },
        series: [{
            type: 'pie',
            name: '教育程度',
            data: datas
        }]
    });
});
</script>
</head>
<body class="nr_bg">
	<div id="container" style="min-width: 400px; height: 400px; margin: 0 auto"></div>
</body>
</html>